curl 登陆 renren
不能用啊~
#!/usr/bin/python # coding:UTF-8 # CopyRight 2011 Adou XD ,All Rights Reserved ''' maybe curl is a better choice ''' import os class renren(): '''''' def login(self ,email ,psd ): logincmd = 'curl -d "email=%s&password=%s&icode=" -D cookie00.txt -b cookie00.txt http://www.renren.com/PLogin.do -o a.html' cmd = logincmd % ( email , psd ) print cmd os.system(cmd) return True def mainpage(self): poststatuscmd = 'curl -o mapg.html -D cookie00.txt -b cookie00.txt http://www.renren.com/261753537' cmd = poststatuscmd os.system(cmd) def poststatus(self,msg): poststatuscmd = 'curl -d "content=%s" -D cookie00.txt -b cookie00.txt http://status.renren.com/doing/updateNew.do' cmd = poststatuscmd % msg os.system(cmd) def postmainstatus(self,msg) : postsmaincmd = 'curl -d "content=%s&isAtHome=1" -D cookie00.txt -b cookie00.txt http://shell.renren.com/601122810/status' cmd = postsmaincmd % msg os.system(cmd) if __name__ == "__main__": me = renren() me.login('username','passworld') #print 'Login Failed!' #sys.exit() me.mainpage() #me.postmainstatus("Hello,Pyton!")
cookie00.txt
HTTP/1.1 302 Found Server: nginx/1.0.10 Date: Sun, 06 May 2012 12:07:20 GMT Connection: keep-alive Location: http://www.renren.com/Login.do?rf=r&domain=renren.com&origURL=http%3A%2F%2Fwww.renren.com%2F261753537 Set-Cookie: anonymid=h1w24479-5atp0b; domain=.renren.com; path=/; expires=Fri, 05-May-2017 12:07:20 GMT Content-Length: 139